$wixFile = [System.IO.Path]::Combine( (Get-Location), $args[0]) 

$doc = new-object System.Xml.XmlDocument
$doc.Load($wixFile)
$nsmgr = new-object System.Xml.XmlNamespaceManager($doc.get_NameTable())
$nsmgr.AddNamespace("ab","http://schemas.microsoft.com/wix/2006/wi")
$featureNode = $doc.SelectSingleNode("/ab:Wix/ab:Product/ab:Feature",$nsmgr)
$componentNodes = $doc.SelectNodes("//ab:Component",$nsmgr)

foreach($comp in $componentNodes)
{
	$newComponentRef = $doc.CreateElement("ComponentRef","http://schemas.microsoft.com/wix/2006/wi")	
	$newComponentRef.SetAttribute("Id",$comp.Id)
	$featureNode.AppendChild($newcomponentref)
}

$doc.Save($wixFile)
